package us.gaaoc.framework.dao;
/*
 * @author Frank
 */
import org.hibernate.Query;

import us.gaaoc.framework.model.DocumentSigConfig;
import us.gaaoc.framework.model.Person;

public class DocumentSigConfigDAOHibernate extends
GenericHibernateDAO<DocumentSigConfig, String, DocumentSigConfigDAO> implements
DocumentSigConfigDAO {
	
	public DocumentSigConfig findCoordinatesByPersonRole(String personRole, String documentCode) {
		Query q = getSession().createQuery("from DocumentSigConfig d where d.personRole = ? and d.documentCode = ?");
		q.setString(0, personRole);
		q.setString(1, documentCode);
		return  (DocumentSigConfig)q.uniqueResult();
	}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.DocumentSigConfigDAO#getDocumentSigConfig(int)
	 */
	public DocumentSigConfig getDocumentSigConfig(int documentCode,  Person personSigned) {
		Query q = getSession().createQuery("from DocumentSigConfig d where d.documentCode.code = ? and " +
				" d.signedByPerson.uuid =?");
		q.setInteger(0,documentCode);
		q.setString(1,personSigned.getUuid());
		return  (DocumentSigConfig)q.uniqueResult();
	}
}